import time
x = 0
while True:
    with open('aaa.txt','a+') as aa:
        aa.write(str(x)+'\n')
        x +=1
        aa.flush()
        print('write:',x)
        time.sleep(1)



